/**
 * Created by Adi(adi@imeth.cn) on 2018/8/30.
 */
import { stringify } from 'qs';
import request from '../utils/request';

// <!---------------------------------------- 银行信息  ------------------------------>

// 获取银行列表
export async function queryBankList(page) {
  return request(`/apis/manager/banks?${stringify(page)}`);
}

// 获取银行详情
export async function getBankById(id) {
  return request(`/apis/manager/banks/${id}`);
}

// 修改银行信息
export async function updateBank(bank) {
  return request(`/apis/manager/banks/${bank.id}`, {
    method: 'PUT',
    body: {
      ...bank,
    },
  });
}

// 新增银行信息
export async function saveBank(bank) {
  return request(`/apis/manager/banks`, {
    method: 'POST',
    body: {
      ...bank,
    },
  });
}

// <!---------------------------------------- 支付通道  ------------------------------>
// 获取支付通道列表
export async function queryPayChannelList(page) {
  return request(`/apis/manager/channels?${stringify(page)}`);
}

// 获取支付通道详情
export async function getPayChannelById(id) {
  return request(`/apis/manager/channels/${id}`);
}

// 新增支付通道
export async function savePayChannel(payChannel) {
  return request(`/apis/manager/channels`, {
    method: 'POST',
    body: {
      ...payChannel,
    },
  });
}

// 修改支付通道
export async function updatePayChannel(payChannel) {
  return request(`/apis/manager/channels/${payChannel.id}`, {
    method: 'PUT',
    body: {
      ...payChannel,
    },
  });
}

// 冻结支付通道
export async function freezePayChannel(id) {
  return request(`/apis/manager/channels/unActivate?${stringify(id)}`);
}

// 激活支付通道
export async function activatePayChannel(id) {
  return request(`/apis/manager/channels/activate?${stringify(id)}`);
}
